<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Vue中的js动画与velocity.js</title>
		<script type="text/javascript" src="js/vue.js" ></script>
		<script type="text/javascript" src="js/velocity.min.js" ></script>
		</style>
	</head>
	<body>
		<div id="root">
			<transition
				name="fade"
				@before-enter="handleBeforeEnter"
				@enter="handleEnter"
				@after-enter="handleAfterEnter"
			>
				<div v-show="show">Hello World</div>
			</transition>
        	<button @click="handleBtnClick">切换</button>
        </div>
		
		<script>
			var vm = new Vue({
				el: '#root',
				data: {
					show: true
				},
				methods: {
					handleBtnClick: function() {
						this.show = !this.show
					},
					handleBeforeEnter: function(el) {
//						el.style.color = "red"
						el.style.opacity = 0;
					},
					handleEnter: function(el, done) {
//						setTimeout(() => {
//							el.style.color = "green"
//						}, 2000)
//						setTimeout(() => {
//							done()
//						}, 4000)
						Velocity(el, {
							opacity: 1
						}, {
							duration: 1000,
							complete: done
						})
					},
					handleAfterEnter: function(el) {
//						el.style.color = "#000"
						console.log("动画结束")
					}
				}
			})
			
		</script>
	</body>
</html>
